package edu.fdzc.learn.service.impl;

import edu.fdzc.learn.entity.Discussions;
import edu.fdzc.learn.entity.vo.DisUsVo;
import edu.fdzc.learn.mapper.DiscussionsMapper;
import edu.fdzc.learn.service.DiscussionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class DiscussuionsServiceImpl implements DiscussionsService {

    @Autowired
    private DiscussionsMapper discussionsMapper;

    @Override
    public void insert(Discussions discussions) {
        discussions.setCreatedAt(LocalDateTime.now());
        discussionsMapper.insert(discussions);
    }

    @Override
    public void delete(int id) {
        discussionsMapper.delete(id);
    }

    @Override
    public List<DisUsVo> selectByCouId(int courseId) {
        List<DisUsVo> list = discussionsMapper.findByCouId(courseId);
        return list;
    }
}
